package edu.stanford.bmir.protege.web.client.ui.ontology.stkos.common.contextMenu;

import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.menu.BaseItem;
import com.gwtext.client.widgets.menu.MenuItem;
import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;

/**
 * Abstract Stkos Tree Node MenuItem
 * 
 * @author LWS
 * 
 */
public abstract class AbstractStkosTreeNodeMenuItem extends MenuItem {

	public AbstractStkosTreeNodeMenuItem(String text, String iconCls,
			boolean disabled) {
		super();
		setText(text == null ? "" : text);
		setIconCls(iconCls);
		setDisabled(disabled);
		addListener(new BaseItemListenerAdapter() {
			@Override
			public void onClick(BaseItem item, EventObject event) {
				super.onClick(item, event);
				AbstractStkosTreeNodeMenuItem.this.onClick(item, event);
			}
		});
	}

	protected void checkNull(Object obj) {
		if (obj == null) {
			throw new NullPointerException("Required argument Can not be null.");
		}
	}

	public abstract void onClick(BaseItem item, EventObject event);
}
